Lesson 2 - Variable quiz
Quiz
str(x) would do what?
- Cast x to a string
- Cast x to a integer
- Cause an error
- Display x as a string
Which of these would convert z to a integer?
- int(z)
- int "z"
- z = int
- cast(z) to int
What is the symbol for assignment?
- =
- !
- #
- (
What is the data type for x?
x = "10"
- integer
- String
- unknown
What is the data type of x?
x = 10
x = str(x)
- integer
- string
- unknown
- will cause an error
What is the data type of x?
x = 10 + "10"
- integer
- string
- unknown
- will cause an error
What would the following code print out?
x = 2
y = 4
print str(y) + str(x)
- 6
- 24
- 42
- Will cause an error
What will this code display?
x = "hello"
y = "20"
z = 4
z = z + int(y)
print x + str(z)
- hello24
- hello204
- 24
- will cause an error